<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="jquery-1.10.2.min.js"></script>
</head>
<body>

<form action="/add.html" method="post">
    姓名：<input type="text" name="name" id="name" value="${student.name}" onblur="check()"/><span id="msg"></span><br/>
    学号：<input type="text" name="id" value="${student.id}"/><br/>
    年龄：<input type="text" name="age" value="${student.age}"/><br/>
    <input type="submit" value="添加" id="btn"/><br/>
</form>
${message}
<script type="text/javascript">
    function check() {
        $.ajax({
            url: "check.html",
            method: "post",
            data: "name=" + $("#name").val(),
            success: function (data) {
                if (!data.status) {
                    $("#btn").attr("disabled", "disabled");
                }else{
                    $("#btn").removeAttr("disabled");
                }
                $("#msg").html(data.msg)
            }
        })
    }
</script>
</body>
</html>
